package com.example.g5project.chat.controller;

import com.example.g5project.chat.model.enumeration.IdentityEnum;
import com.example.g5project.chat.model.param.AccountImportParam;
import com.example.g5project.chat.util.IMUserIdUtils;
import com.example.g5project.others.ResponseValue;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 单独提供账号导入接口供小程序调用
 * @Author
 * @Date 2022/4/4 3:38 下午
 */
@RestController
@RequestMapping("/api/consulting/account")
public class IMChontroller {

    @Autowired
    private IMUserIdUtils imUserIdUtils;

    @PostMapping("/import")
    public ResponseValue<String> importAccount(@RequestBody @Valid AccountImportParam accountImportParam) {
        String imUserId = imUserIdUtils.importUserId(accountImportParam.getUserId(), IdentityEnum.parseById(accountImportParam.getUserIdentity()));
        return ResponseValue.success(imUserId);
    }

}
